package com.dragon.repository.domain.dto;

import com.dragon.common.util.BeanUtils;
import com.dragon.repository.entity.AttendanceReplace;
import com.dragon.repository.entity.OtherFile;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonInclude;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;


/**
 * @author sy
 */
@Data
@JsonInclude(JsonInclude.Include.NON_NULL)
public class AttendanceReplaceDTO {

    private static final long serialVersionUID = 1L;

    @ApiModelProperty(value = "id")
    private Integer id;

    @ApiModelProperty(value = "补卡类型： 1：上班补卡2：下班补卡")
    private Integer replaceType;

    @ApiModelProperty(value = "补卡时间")
    @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
    private Date replaceTime;

    @ApiModelProperty(value = "补卡事由")
    private String replaceCase;

    @ApiModelProperty(value = "附件")
    private List<OtherFile> otherFiles;

    @ApiModelProperty(value = "用户id")
    private Integer adminId;

    @ApiModelProperty(value = "状态：0 待审核 1审核通过 2审核不通过 3作废 4删除")
    private Integer status;

    @ApiModelProperty(value = "考勤子表id")
    private Integer attendanceChildId;

    @ApiModelProperty(value = "创建时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date createTime;


    public AttendanceReplaceDTO() {}

    public AttendanceReplaceDTO(AttendanceReplace entity) {
        BeanUtils.copyProperties(entity,this);
    }

    public static AttendanceReplaceDTO convert(AttendanceReplace entity) {
        return new AttendanceReplaceDTO(entity);
    }

    public static List<AttendanceReplaceDTO> convertList(List<AttendanceReplace> list) {
        List<AttendanceReplaceDTO> resultList = new ArrayList<>();
        for (AttendanceReplace entity : list) {
            resultList.add(new AttendanceReplaceDTO(entity));
        }
        return resultList;
    }}
